//
//  MSCustomerMatchingCell.m
//  SocietySale
//
//  Created by Mike on 16/11/18.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSCustomerMatchingCell.h"

@interface MSCustomerMatchingCell ()
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *phoneLabel;
@property (nonatomic, strong) UILabel *projectLabel;
@end

@implementation MSCustomerMatchingCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView {
    self.nameLabel = [self creatLabel:CGRectMake(12, 11, SCREEN_WIDTH-12, 20)];
    self.phoneLabel = [self creatLabel:CGRectMake(12, self.nameLabel.bottom+8, SCREEN_WIDTH-12, 40)];
    self.phoneLabel.numberOfLines = 0;
    self.projectLabel = [self creatLabel:CGRectMake(12, self.phoneLabel.bottom+8, SCREEN_WIDTH-12, 20)];
    
    _horizonLineView =[[UIView alloc] initWithFrame:CGRectMake(12, 44.4, SCREEN_WIDTH-24, 0.6)];
    _horizonLineView.backgroundColor = kNormalGray;
    [self.contentView addSubview:_horizonLineView];
}

//创建label
- (UILabel*)creatLabel:(CGRect)frame{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = HeitiFont(14);
    label.textColor = kLightBlackColor;
    [self addSubview:label];
    return label;
}

- (void)setModel:(MSDetailContactModel *)model{
    _model = model;
    
    NSMutableAttributedString *nameAttStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@  ",model.name]];
    NSAttributedString *position = [[NSAttributedString alloc] initWithString:model.position attributes:@{NSForegroundColorAttributeName:kDarkGrayColor}];
    [nameAttStr appendAttributedString:position];

    self.nameLabel.attributedText = nameAttStr;
    
    NSMutableAttributedString *phoneAttStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n",model.telephone] attributes:@{NSForegroundColorAttributeName:kCyanColor}];
    NSAttributedString *company = [[NSAttributedString alloc] initWithString:model.company];
    [phoneAttStr appendAttributedString:company];
    
    self.phoneLabel.attributedText = phoneAttStr;
    
    self.projectLabel.text = model.source;
}

@end
